package com.cly.controller;

import com.cly.result.JsonRequest;
import com.cly.service.ICourseStatisticsService;
import com.cly.statistics.PieStatistics;
import com.cly.statistics.SumStatistics;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 课程统计控制类
 *
 * @author by 春风能解释
 * <p>
 * 2024/10/15
 */
@RestController
@RequestMapping("/courseChats")
@RequiredArgsConstructor
@Tag(name = "课程统计控制类", description = "课程统计操作访问接口")
public class CourseStatisticsController {

    /**
     * 课程统计服务
     */
    private final ICourseStatisticsService courseStatisticsService;

    /**
     * 课程总数统计
     *
     * @return 课程总数
     */
    @GetMapping("/count")
    @Operation(summary = "课程总数统计")
    public JsonRequest<List<SumStatistics<Long>>> sumStatisticsCourse() {
        return courseStatisticsService.sumStatisticsCourse();
    }

    /**
     * 课程类型统计
     *
     * @return 课程类型
     */
    @GetMapping("/typePie")
    @Operation(summary = "课程类型统计")
    public JsonRequest<List<PieStatistics<Long>>> sumStatisticsCourseType() {
        return courseStatisticsService.sumStatisticsCourseType();
    }

}
